package com.acwing.partition11;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class AC1052设计密码 {

    private static final int MOD = (int) (1e9 + 7);
    
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(reader.readLine().split("\\s+")[0]);
        String s = reader.readLine();
        writer.write(String.valueOf(dynamicProgramming(n, s)));
        writer.flush();
    }

    private static int dynamicProgramming(int n, String t) {
        int m = t.length();
        char[] s = t.toCharArray();
        int[] next = new int[m];
        for (int i = 1, j = 0; i < m; i++) {
            while (j > 0 && s[i] != s[j]) j = next[j - 1];
            if (s[i] == s[j]) j++;
            next[i] = j;
        }
        //dp[i][j]表示对于密码长度是n，s[0,j]不能在密码中出现的方案数
        int[][] dp = new int[n + 1][m + 1];
        dp[0][0] = 1;
        //枚举密码的每一位
        for (int i = 0; i < n; i++) {
            //枚举不能出现的字符的每一位
            for (int j = 0; j < m; j++) {
                //枚举密码i处可以出现的字符，对这个位置的每一种字符都进行kmp匹配，
                for (char ch = 'a'; ch <= 'z'; ch++) {
                    int u = j;
                    while (u > 0 && s[u] != ch) u = next[u - 1];
                    if (s[u] == ch) u++;
                    if (u < m) dp[i + 1][u] = (dp[i + 1][u] + dp[i][j]) % MOD;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++) ans = (ans + dp[n][i]) % MOD;
        return ans;
    }
}
